<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			
		</div>
		<script src="../vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
		<script type="text/javascript">
			
			axios.defaults.baseURL="http://localhost:8080"
			axios.interceptors.response.use(function(res) {
				return res.data
			}, function() {
				return err
			})
			
			var vm = new Vue({
				el: '#app',
				data: {
					name: '',
					list: []
				},
				methods: {
					getData: async function() {
						this.list = await axios.get('books')
					},
					add() {
						var ret = await axios.post('books', {
							name: this.name
						})
						if (ret.status == 200) {
							this.getData()
						}
					}
				},
				mounted: function() {
					this.getData()
				}
			})
		</script>
	</body>
</html>
